﻿using System.Collections.Generic;
using ArmyManager.Items;

namespace ArmyManager.Commands
{
	public class FuseItemsCommand : BasicCommand
	{
		private readonly Armory _armory;
		private readonly Item _primaryItem;
		private readonly Item _secondaryItem;
		private readonly Item _fusedItem;

		public FuseItemsCommand(Armory armory, Item primaryItem, Item secondaryItem)
		{
			_armory = armory;
			_primaryItem = primaryItem;
			_secondaryItem = secondaryItem;
			_fusedItem = _primaryItem + _secondaryItem;
		}

		protected override void ExecuteInternal()
		{
			_armory.RemoveItem(_primaryItem);
			_armory.RemoveItem(_secondaryItem);
			_armory.AddItem(_fusedItem);
		}

		protected override void UndoInternal()
		{
			_armory.RemoveItem(_fusedItem);
			_armory.AddItem(_primaryItem);
			_armory.AddItem(_secondaryItem);
		}
	}
}